home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Design
/
WB Collection.iso
/
workbench werkzeuge
/
icon tools
/
makeicons
/
makeicons.ifx
< prev
next >
Wrap
Text File
|
1996-04-07
|
3KB
|
146 lines
/*
* Arexx Macro for creating icons from images
* Created by Per Espen Hagen
* $VER: MakeIcons 1.5 (7.8.1994)
*
*/
OPTIONS RESULTS
CALL AddLib("rexxreqtools.library", 0, -30, 0)
/****** Get user input ******/
RollScreenUp 400
CALL RTFileRequest(, , "Select image files", , "rtfi_flags=freqf_multiselect", InFiles)
RollScreenDown
IF InFiles ~= 1 THEN DO
RequestNotify "No files selected"
Exit
END
/* Options requester */
Gad.1 = 'J/80/17/25/Brightness:/0'
Gad.2 = 'J/80/32/25/Contrast:/20'
Gad.3 = 'J/80/47/25/Gamma:/30'
Gad.4 = 'J/180/17/25/Max Size:/80'
Gad.5 = 'J/180/32/25/Step Size:/4'
Gad.6 = 'J/180/47/25/Bitplanes:/3'
Gad.7 = 'X/230/17/Use Aspect?/1'
Gad.8 = 'X/230/32/Colours?/1'
Gad.9 = 'X/230/47/Lock GUI?/0'
ComplexRequest '"MakeIcons"' 9 Gad 345 83
Bri = Result.1
Con = Result.2
Gam = Result.3
MaxSize = Result.4
StepSize = Result.5
Planes = Result.6
UseAsp = Result.7
Colours = Result.8
Lock = Result.9
/****** Convert & check input validity ******/
SELECT
WHEN Planes = 1 THEN NCol = 2
WHEN Planes = 2 THEN NCol = 4
WHEN Planes = 3 THEN NCol = 8
WHEN Planes = 4 THEN NCol = 16
WHEN Planes = 5 THEN NCol = 32
WHEN Planes = 6 THEN NCol = 64
WHEN Planes = 7 THEN NCol = 128
WHEN Planes = 8 THEN NCol = 256
OTHERWISE
RequestNotify "Planes must be in the range 1-8"
Exit
END
/****** Initialize ImageFX ******/
/* Disable Undo, if enabled */
GetPrefs Undo
PrefUndo = Result
SetPrefs Undo OFF
/* Set a few render options */
Palette 8
LockRange 0 OFF
LoadPalette "Palettes/Workbench.palette" '-1'
LockRange 0 ON
Render Dither 1 0 0
Render ModeID 692228
Render Colors NCol
/****** Main Loop ******/
DO FrameNo = 1 TO InFiles.count
IF Lock THEN LockGUI
/* Load a picture */
LoadBuffer InFiles.FrameNo Force NOSMOOTH
GetMain
IF Result = "" THEN DO
RequestNotify "Unable to load file. Out of memory?"
END
ELSE DO
Data = Result
PARSE VAR Data Name W H Depth AspX AspY Dummy
/* Possible aspect adjustment */
IF UseAsp THEN DO
W = W * AspX
H = H * AspY
END
IF W > H THEN DO
IconW = MaxSize
IconH = ((H*IconW/W + StepSize - 1) % StepSize) * StepSize
END
ELSE DO
IconH = MaxSize
IconW = ((W*IconH/H + StepSize - 1) % StepSize) * StepSize
END
Scale IconW IconH
/* Convert to B/W, if desired */
IF Depth = 3 & ~Colours THEN
ColorToGray Luma
/* Convert to colour, if necessary */
IF Depth = 1 THEN
GreyToColor
/* Contrast enhancement */
Brightness Bri
Contrast Con
Gamma Gam
/* Render the icon and save it */
Render Go
SaveRenderedAs Amiga InFiles.FrameNo FORCE
Render Close
/* Add default tool to icon */
ADDRESS COMMAND
NewTool InFiles.FrameNo
ADDRESS
/* Unlock GUI to give user some info what's happening */
UnlockGUI
END
END
/* Reset Undo to previous state */
SetPrefs Undo PrefUndo